package com.itheima.dcp.demo1;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Demo {
    public static void main(String[] args) throws UnknownHostException {
        InetAddress byName = InetAddress.getByName("lidandan");//小括号里也可以给主机名,也可以给域名
        String hostName = byName.getHostName();
        System.out.println("主机名"+hostName);
        String hostAddress = byName.getHostAddress();
        System.out.println("Ip为:"+hostAddress);
    }
}
